<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>6.33. Flex-2.5.33</title>
    <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type="text/css" media="print" />
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head>
  <body id="lfs" class="6.2">
    <div class="navheader">
      <div class="headertitles">
        <h4>Linux From Scratch - 版本 6.2</h4>
        <h3>第六章 安装系统基础软件</h3>
      </div>
      <ul class="headerlinks">
        <li class="prev">
          <a accesskey="p" href="findutils.html" title="Findutils-4.2.27">后退</a>
          <p>Findutils-4.2.27</p>
        </li>
        <li class="next">
          <a accesskey="n" href="grub.html" title="GRUB-0.97">前进</a>
          <p>GRUB-0.97</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a></li>
      </ul>
    </div>
    <div class="wrap">
      <div class="titlepage">
        <h1 class="sect1">6.33. Flex-2.5.33</h1>
      </div>
      <div class="package">
        <p>Flex 软件包包含一个能生成识别文本模式的程序的工具。</p>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">预计编译时间：</span></strong> <span class="seg">0.1 SBU</span>
            </div>
            <div class="seg">
              <strong><span class="segtitle">所需磁盘空间：</span></strong> <span class="seg">8.4 MB</span>
            </div>
          </div>
        </div>
      </div>
      <div class="installation">
        <div class="titlepage">
          <h2 class="sect2">6.33.1. 安装 Flex</h2>
        </div>
        <p>为编译 Flex 做准备：</p>
        <pre class="userinput"><kbd class="command">./configure --prefix=/usr</kbd></pre>
        <p>编译软件包：</p>
        <pre class="userinput"><kbd class="command">make</kbd></pre>
        <p>要测试结果，请运行：<strong class="userinput"><tt>make check</tt></strong> 。</p>
        <p>安装软件包：</p>
        <pre class="userinput"><kbd class="command">make install</kbd></pre>
        <p>一些程序试图在 <tt class="filename">/usr/lib</tt> 下面寻找 <tt class="filename">lex</tt> 库，可以创建一个符号链接来满足要求：</p>
        <pre class="userinput"><kbd class="command">ln -sv libfl.a /usr/lib/libl.a</kbd></pre>
        <p>一些程序并不知道 <span><strong class="command">flex</strong></span> 而是试图寻找 <span><strong class="command">lex</strong></span> 程序(flex 是实现 lex 功能的另一种也是更好的选择)。为了满足少数一些程序的需要，我们将创建一个 <tt class="filename">lex</tt> 脚本，这个脚本调用 <tt class="filename">flex</tt> 并通过它来模仿 <span><strong class="command">lex</strong></span> 的输出文件命名惯例：</p>
        <pre class="userinput"><kbd class="command">cat &gt; /usr/bin/lex &lt;&lt; "EOF"
<tt class="literal">#!/bin/sh
# Begin /usr/bin/lex

exec /usr/bin/flex -l "$@"

# End /usr/bin/lex</tt>
EOF
chmod -v 755 /usr/bin/lex</kbd></pre>
      </div>
      <div class="content">
        <div class="titlepage">
          <a id="contents-flex" name="contents-flex"></a>
          <h2 class="sect2">6.33.2. Flex 的内容</h2>
        </div>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">安装的程序：</span></strong> <span class="seg">flex, lex</span>
            </div>
            <div class="seg">
              <strong><span class="segtitle">安装的库：</span></strong> <span class="seg">libfl.a</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3><a id="id3686258" name="id3686258"></a>简要描述</h3>
          <table border="0">
            <col align="left" valign="top" />
            <tbody>
              <tr>
                <td><a id="flex" name="flex"></a><span class="term"><span><strong class="command">flex</strong></span></span></td>
                <td><p>是一个用来生成识别文本的模式程序的工具。模式识别在很多程序中是非常有用，用户设置一些查询规则，然后 flex 可以生成一个查询程序。人们使用 flex 可以比亲自编写查询程序更便捷。</p></td>
              </tr>
              <tr>
                <td><a id="lex" name="lex"></a><span class="term"><span><strong class="command">lex</strong></span></span></td>
                <td><p>在 <span><strong class="command">lex</strong></span> 仿真模式下运行 <span><strong class="command">flex</strong></span> 的一个脚本</p></td>
              </tr>
              <tr>
                <td><a id="libfl.a" name="libfl.a"></a><span class="term"><tt class="filename">libfl.a</tt></span></td>
                <td><p><tt class="filename">flex</tt> 库</p></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="findutils.html" title="Findutils-4.2.27">后退</a>
          <p>Findutils-4.2.27</p>
        </li>
        <li class="next">
          <a accesskey="n" href="grub.html" title="GRUB-0.97">前进</a>
          <p>GRUB-0.97</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a>.
        </li>
      </ul>
    </div>
</body></html>
